package operation.iterator.obj.aggregates;

import java.util.Iterator;

import operation.iterator.abs.ICollege;
import operation.iterator.obj.Department;
import operation.iterator.obj.iterators.ComputerCollegeIterator;

public class ComputerCollege implements ICollege {

    Department[] departments;
    int size, capacity;

    public ComputerCollege() {
        capacity = 3;
        size = 0;
        departments = new Department[capacity];
        departments[size++] = new Department("Software Engineering");
        departments[size++] = new Department("Big Data");
        departments[size++] = new Department("AI");
    }

    @Override
    public Iterator<Department> iterator() {
        return new ComputerCollegeIterator(departments);
    }

    @Override
    public void addDepartment(String name) {
        if (size < capacity) {
            departments[size++] = new Department(name);
        }
    }
    
}